package com.yitong.Estshopping.entity;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.hibernate.annotations.SelectBeforeUpdate;

import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.annotation.JsonIgnore;

/**
 * Model class of image.
 * 
 * @author generated by ERMaster
 * @version $Id$
 */
@Table(name="image")
@Entity
@SelectBeforeUpdate
public class Image implements Serializable {

	/** serialVersionUID. */
	private static final long serialVersionUID = 1L;

	/** imgid. */
	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	@Column(name="imgid")
	private Integer imgid;

	/** imgsrc. */
	@Column(name="src")
	private String src;
	/** imgsrc. */
	@Column(name="color")
	private String color;
	@Column(name="uname")
	private String uname;

	/** state. */
	@Column(name="state")
	private Integer state;

	/** name. */
	@Column(name="title")
	private String title;
	/** classify.分类 */
	/** 图片宽度 */
	@Column(name="width")
	private Integer width;
	/** 图片高度 */
	@Column(name="height")
	private Integer height;

	@JoinColumn(name = "uid")
	@ManyToOne
	@JsonIgnore
	private User user;
	@JoinColumn(name = "pid")
	@ManyToOne
	@JsonIgnore
	private Product product;
	public Integer getImgid() {
		return imgid;
	}
	public void setImgid(Integer imgid) {
		this.imgid = imgid;
	}
	public String getSrc() {
		return src;
	}
	public void setSrc(String src) {
		this.src = src;
	}
	public String getColor() {
		return color;
	}
	public void setColor(String color) {
		this.color = color;
	}
	public String getUname() {
		return uname;
	}
	public void setUname(String uname) {
		this.uname = uname;
	}
	public Integer getState() {
		return state;
	}
	public void setState(Integer state) {
		this.state = state;
	}
	public String getTitle() {
		return title;
	}
	public void setTitle(String title) {
		this.title = title;
	}
	public Integer getWidth() {
		return width;
	}
	public void setWidth(Integer width) {
		this.width = width;
	}
	public Integer getHeight() {
		return height;
	}
	public void setHeight(Integer height) {
		this.height = height;
	}
	public User getUser() {
		return user;
	}
	public void setUser(User user) {
		this.user = user;
	}
	public Product getProduct() {
		return product;
	}
	public void setProduct(Product product) {
		this.product = product;
	}
	
	@Override
	public String toString() {
		Map<String, Object> map= new HashMap<>();
		map.put("color", color);
		map.put("height", height);
		map.put("src", src);
		map.put("width", width);
		map.put("uid", user.getUid());
		map.put("uname", user.getName());
		String jsonString = JSONObject.toJSONString(map);
		return jsonString;
	}
	
}
